package com.chen.controller;

import com.alibaba.fastjson.JSON;
import com.chen.pojo.Release;
import com.chen.service.release.ReleaseService;
import com.chen.util.SystemConstrant;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/release")
public class ReleaseController {

    @Resource
    private ReleaseService releaseService;

    /**
     * 添加订单
     * @param release
     * @return
     */
    @RequestMapping(value = "/addRelease",produces = {"application/json;charset=UTF-8"})
    @ResponseBody
    public String addRelease(Release release){
        Map<String, Object> map = new HashMap<String, Object>();
        if (releaseService.addRelease(release)>0){
            map.put(SystemConstrant.SUCCESS,true);
            map.put(SystemConstrant.MESSAGE,"球场预约成功");
        }else{
            map.put(SystemConstrant.SUCCESS,false);
            map.put(SystemConstrant.MESSAGE,"球场预约失败，请重试！");
        }
        return JSON.toJSONString(map);
    }
}
